package com.lhjz.portal.entity.security;
// default package
// Generated May 6, 2015 11:39:38 AM by Hibernate Tools 4.3.1

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.util.Objects;

/**
 * GroupAuthority generated by hbm2java
 */
@Entity
@Table(name = "group_authorities")
public class GroupAuthority implements java.io.Serializable {

    /**
     * serialVersionUID long
     */
    private static final long serialVersionUID = -8028884450384610029L;
    private GroupAuthorityId id;
    private Group group;

    public GroupAuthority() {
    }

    public GroupAuthority(GroupAuthorityId id, Group group) {
        this.id = id;
        this.group = group;
    }

    @EmbeddedId
    @AttributeOverrides({@AttributeOverride(name = "groupId", column = @Column(name = "group_id", nullable = false)),
            @AttributeOverride(name = "authority", column = @Column(name = "authority", nullable = false, length = 50))})
    public GroupAuthorityId getId() {
        return this.id;
    }

    public void setId(GroupAuthorityId id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "group_id", nullable = false, insertable = false, updatable = false)
    public Group getGroup() {
        return this.group;
    }

    public void setGroup(Group group) {
        this.group = group;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        GroupAuthority that = (GroupAuthority) o;
        return Objects.equals(id, that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
